#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=2e5+1000;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL a[maxn],siz[maxn],fa[maxn],vis[maxn];
LL find(LL x){
    if(fa[x]!=x) return fa[x]=find(fa[x]);
    else return fa[x];
}
void unio(LL x,LL y){
   LL u=find(x);LL v=find(y);
   if(u!=v){
      if(siz[u]>siz[v]){
           siz[u]+=siz[v];
           siz[v]=0;
           fa[v]=u;
      }
      else{
         siz[v]+=siz[u];
         siz[u]=0;
         fa[u]=v;
      }
   }
}
int main(void){
   	cin.tie(0);std::ios::sync_with_stdio(false);
   	LL n;cin>>n;
    for(LL i=1;i<=n;i++){
        cin>>a[i];
        fa[i]=i;
        siz[i]=1;
        vis[a[i]]=fa[i];
    }
    for(LL i=1;i<=n;i++){
        if(vis[a[i]-1]){
            unio(vis[a[i]],vis[a[i]-1]);
        }
        if(vis[a[i]+1]){
            unio(vis[a[i]],vis[a[i]+1]);
        }
    }
    LL ans=1;
    for(LL i=1;i<=n;i++){
        ans=max(ans,siz[i]);
    }
    cout<<ans<<"\n";
   	return 0;
}
